package jiemi;
import java.io.*;
import java.util.Scanner;
public class stay {
    /** Main method
     @param args[0] for sourcefile
     @param args[1] for target file
     */
    public static void main(String[] args) throws IOException {
        // Check command-line parameter usage
        Scanner m1 = new Scanner(System.in);

        System.out.println("输入一个源文件名");
        String Filename = m1.nextLine();
        System.out.println("请再输入一个加密文件名");
        String Filename1 = m1.nextLine();

        File sourceString = new File(Filename);
        if (!sourceString.exists()) {
            System.out.println("Source file " + Filename
                    + " does not exist");
            System.exit(2);
        }
        File targetString = new File(Filename1);
        if (targetString.exists()) {
            System.out.println("Target file " + Filename1
                    + " already exists");
            System.exit(3);
        }
        if (args.length != 2) {
            System.out.println(
                    "Usage: java Copy sourceFile targetString");
            System.exit(1);
        }
        try (
                // Create an input stream
                BufferedInputStream input =
                        new BufferedInputStream(new FileInputStream(sourceString));

                // Create an output stream
                BufferedOutputStream output =
                        new BufferedOutputStream(new FileOutputStream(targetString));
        ) {
            // Continuously read a byte from input and write it to output
            int r, numberOfBytesCopied = 0;
            while ((r = input.read()) != -1) {
                output.write((byte)(r+5));
                numberOfBytesCopied++;
            }

            // Display the file size
            System.out.println(numberOfBytesCopied + " bytes copied");

        }
    }
}


